package dd.prog2.exercises.set09;

import java.util.Iterator;

public class MyDequeUtil<T> {

	private MyDequeUtil(){
	}

	public static <T> MyDeque<T> merge(MyDeque<T> d, MyDeque<T> d2) {
		MyDeque<T> tmp = new MyDeque<T>(d.size() + d2.size());
		Iterator<T> i = d.iterator();
		while (i.hasNext()) {
			tmp.addLast(i.next());
		}
		Iterator<T> i2 = d2.iterator();
		while (i2.hasNext()) {
			tmp.addLast(i2.next());
		}
		return tmp;
	}

	public static <T extends Comparable<T>> MyDeque<T> selectLess(MyDeque<T> d, T i) {
		MyDeque<T> tmp = new MyDeque<T>(d.size());
		Iterator<T> it = d.iterator();
		while (it.hasNext()) {
			T dTmp = it.next();
			if (dTmp.compareTo(i) < 0)
				tmp.addLast(dTmp);
		}
		return tmp;
	}

}
